<?php
//ini_set('display_errors','off');
ini_set('log_errors','off');
ini_set('display_startup_errors','on');
function watchdog_error_catch ($errno = 0, $errstr = '', $errfile = '', $errline = 0, $errcontext = array()) {
	$date = date('[d.m.Y H:m] ');
	$error = "Error $errno in $errfile : $errline.\n"
	.str_replace("\n",'',strip_tags($errstr))
	."\nContext ".substr(print_r($errcontext,true),6);
	error_log("*** $date $error",3,'__logs__/errorlog.txt');
	print "*** $date $error\n";
	callback_module::run('callback_error_log',array($errno, $errstr, $errfile, $errline, $errcontext));
	//debug_print_backtrace();
}
set_error_handler ('watchdog_error_catch',E_ALL);
function watchdog_exception_catch ($e) {
	$error = "Exception ".$e->getCode()." uncaught: ".$e->getMessage()."\n".$e->getTraceAsString();
	error_log($error,3,'__logs__/errorlog.txt');
	print "*** $error\n";
	callback_module::run('callback_exception',array($e));
}
?>
